﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Text;
using DTcms.Common;

namespace DTcms.Web
{
    public partial class EntertainmentContent : System.Web.UI.Page
    {
        protected Model.article modelA;
        protected DataTable dtMenu = null;
        //protected string connnt = "";
        protected int _id = 0;
        protected int _aid = 0;
        protected string id = "";
        protected void Page_Load(object sender, EventArgs e)
        {
            _id = DTRequest.GetQueryInt("id");
            id = _id.ToString();
            _aid = DTRequest.GetQueryInt("aid");
            TeamListBing();
            MenuListBing();
            ArticleBing();

        }
        private void TeamListBing()
        {
            rptTeam.DataSource = new BLL.article_category().GetList(2, 2);
            rptTeam.DataBind();
        }
        private void MenuListBing()
        {
            if (_id != 0)
            {
                Model.article_category model = new BLL.article_category().GetModel(_id);
                Model.article_category modelP = new BLL.article_category().GetModel(model.parent_id);
                StringBuilder html = new StringBuilder();
                html.Append("<a href=\"/index.aspx\">主页</a>");
                if (modelP != null)
                {
                    html.Append("> <a href=\"" + modelP.link_url + "?id=" + modelP.id + "\">" + modelP.title + "</a>");
                }
                if (model != null)
                {
                    html.Append("> <a href=\"" + model.link_url + "?id=" + model.id + "\">" + model.title + "</a>");
                }
                memu.InnerHtml = html.ToString();
            }
        }

        private void ArticleBing()
        {
            if (_aid > 0)
            {
                modelA = new BLL.article().GetModel(_aid);

            }
            else if (_id > 0)
            {
                modelA = new BLL.article().GetModelByWhere("category_id=" + _id);
            }

            if (modelA != null)
            {
                Model.article nextModel = new BLL.article().GetModelByWhere("category_id=" + _id + " and id>" + modelA.id);
                Model.article prevModel = new BLL.article().GetModelByWhere("category_id=" + _id + " and id<" + modelA.id);

                if (nextModel != null)
                {
                    btnnext.NavigateUrl = String.Format("EntertainmentContent.aspx?id={0}&aid={1}", _id, nextModel.id);
                }
                if (prevModel != null)
                {
                    btnprev.NavigateUrl = String.Format("EntertainmentContent.aspx?id={0}&aid={1}", _id, prevModel.id);
                }
            }
        }
    }


}